﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

namespace WebApplication3
{
    public class Dbhelper
    {
        private static readonly string conString = "server = .;Database = Admin2000 ; Uid = sa ;Password = 123456 ";


        public static DataTable GetDatatable  (string sql)
        {
            SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, conString );
            DataTable table = new DataTable();
            dataAdapter.Fill(table);
            return table;

        }


        public static int AddOrDeleteOrUpdate (string sql)
        {
            SqlConnection connection = new SqlConnection(conString );
            SqlCommand command = new SqlCommand(sql, connection);
            connection.Open();
            var result = command.ExecuteNonQuery();
            connection.Close();
            return result;


        }

    }
}